package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.MaintainPlan;
import com.indusfo.spc.pojo.MaintainPlanDetail;
import com.indusfo.spc.service.MaintainPlanService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 设备保养项目controller
 */
@Controller
@RequestMapping("/service/maintainPlan")
public class MaintainPlanController {
    @Resource
    MaintainPlanService maintainPlanService;

    /**
     * 新增设备保养项目
     * @param maintainPlan
     * @return
     */
    @ResponseBody
    @RequestMapping("/insertMaintainPlan")
    JSONObject insertMaintainPlan(MaintainPlan maintainPlan, Integer[] maintainIds){
        return maintainPlanService.insertMaintainPlan(maintainPlan,maintainIds);
    }

    /**
     * 查询设备保养项目明细
     * @param maintainPlanDetail
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMaintainPlanDetail")
    JSONObject queryMaintainPlanDetail(MaintainPlanDetail maintainPlanDetail){
            return maintainPlanService.queryMaintainPlanDetail(maintainPlanDetail);
    }

    /**
     * 编辑设备保养项目
     * @param maintainPlan
     * @return
     */
    @ResponseBody
    @RequestMapping("/updateMaintainPlan")
    JSONObject updateMaintainPlan(MaintainPlan maintainPlan,Integer[] maintainIds){
            return maintainPlanService.updateMaintainPlan(maintainPlan,maintainIds);
    }

    /**
     * 审核状态修改
     * @param maintainPlanIds
     * @param auditState
     * @return
     */
    @ResponseBody
    @RequestMapping("/auditStateChange")
    JSONObject auditStateChange(Integer[] maintainPlanIds,Integer auditState,Integer[] auditStateIds){
            return maintainPlanService.auditStateChange(maintainPlanIds,auditState,auditStateIds);
    }

    /**
     * 查询设备保养项目
     * @param maintainPlan
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMaintainPlan")
    JSONObject queryMaintainPlan(MaintainPlan maintainPlan,String startDate,String endDate){
        return maintainPlanService.queryMaintainPlan(maintainPlan,startDate,endDate);
    }

    /**
     * 数据状态修改
     * @param maintainPlanIds
     * @param dataState
     * @return
     */
    @ResponseBody
    @RequestMapping("/defineDataState")
    JSONObject defineDataState(Integer[] maintainPlanIds,Integer dataState,Integer[] auditState){
        return maintainPlanService.defineDataState(maintainPlanIds,dataState,auditState);
    }
    /**
     * 新增设备保养计划明细时查询保养项目
     * @param maintainPlan
     * @return
     */
    @ResponseBody
    @RequestMapping("/filterMaintainList")
    JSONObject filterMaintainList(MaintainPlan maintainPlan,Integer[] maintainIds){
        return maintainPlanService.filterMaintainList(maintainPlan,maintainIds);
    }


    /**
     * 查询指定设备的保养项目
     * @param deviceId
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMaintainByDevice")
    JSONObject queryMaintainByDevice(Integer deviceId){
        return maintainPlanService.queryMaintainByDevice(deviceId);
    }


}
